home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc2 / iffmst16.lha / IFFMaster / rexx / RemoveANNO.rexx < prev    next >
OS/2 REXX Batch file  |  1996-05-04  |  3KB  |  102 lines

  1. /*
  2. **  $VER: RemoveANNO.rexx (23 Mar 1996)  **
  3. **
  4. **        © 1996 Kay Drangmeister
  5. **
  6. **
  7. **  PROGRAMNAME:
  8. **      RemoveANNO
  9. **
  10. **  FUNCTION:
  11. **      Scans directory and removes ANNO chunk from every file it finds.
  12. **
  13. **      WARNING: This script OVERWRITES your files with the shortened ones
  14. **               after having asked the user to do so.
  15. **               Use at your own risk!
  16. **
  17. **  $HISTORY:
  18. **
  19. **   23 Mar 1996 : 1.0 : initial release
  20. */
  21.  
  22.  
  23. PortName    = 'IFFMASTER.1'           /* portname, usually IFFMASTER.1 */
  24. LF          = '0a'x                   /* linefeed */
  25. iffmpath    = 'IFFMaster'             /* change this to your path */
  26.  
  27. PARSE ARG LoadPath .
  28. IF (LoadPath=="") THEN DO
  29.     SAY "USAGE: RemoveANNO.rexx <directory>" LF "      WARNING: Overwrites files (but asks before doing it)"
  30.     EXIT 0
  31. END
  32.  
  33. ADDRESS VALUE PortName
  34.  
  35. IFFMACTIVE=1
  36. IF ~SHOW('Ports',PortName) THEN DO
  37.     IFFMACTIVE=0        /* indicate that we did start IFFMaster through the script */
  38.     ADDRESS 'COMMAND' 'Run >NIL: 'iffmpath
  39.     ADDRESS 'COMMAND' 'WaitForPort '||PortName
  40.     IF ~SHOW('Ports',PortName) THEN EXIT 10
  41. END
  42.  
  43. IF ~SHOW('l','rexxsupport.library') THEN DO
  44.     CALL addlib('rexxsupport.library',0,-30)
  45. END
  46.  
  47. OPTIONS RESULTS
  48.  
  49.  
  50. 'limithex bytes 16'     /* we ignore hex dumps */
  51.  
  52. dd = showdir(LoadPath,"FILE")    /* build list of files */
  53. numfiles = words(dd)
  54. j=0
  55. DO i=1 to numfiles
  56.     fn = WORD(dd,i)
  57.     IF (upper(right(fn,5))~=".INFO") THEN DO
  58.         j=j+1
  59.         FileName.j=fn
  60.         /* say "found " || LoadPath || FileName.j */
  61.     END
  62. END
  63. numfiles=j
  64.  
  65. 'showformat 4' /* show quick chunk contents in chunk list */
  66. DO i=1 to numfiles
  67.     'load 'LoadPath || FileName.i
  68.     changed=0
  69.     'entries'; nument=RESULT
  70.     count=0
  71.     DO j=0 FOR nument;
  72.         'cursorpos 'j
  73.         'chunkid'; ID=RESULT
  74.         IF ID='ANNO' THEN DO
  75.             'chunktext'
  76.             anno=RESULT
  77.             ADDRESS COMMAND 'RequestChoice >env:removeannorexxvar "RemoveANNO request" "In file *"' || FileName.i || '*",*Ndelete chunk with contents*N*"' || anno || '*"?" "Yes" "NO"'
  78.             OPEN("RAVar","env:removeannorexxvar","R")
  79.             var=READLN("RAVar")
  80.             CLOSE("RAVar")
  81.             DELETE("env:removeannorexxvar")
  82.             IF (var=1) THEN DO
  83.                 'editable on'
  84.                 'overwrite on'
  85.                 'delete'
  86.                 changed=1
  87.             END
  88.             LEAVE
  89.         END
  90.     END
  91.     IF changed=1 THEN 'save'
  92. END
  93.  
  94.  
  95. IF IFFMACTIVE=0 THEN DO
  96.     ADDRESS Value portname
  97.     'quit'     /* we started IFFMaster ourselves, so close it */
  98. END
  99.  
  100. EXIT(0)
  101.  
  102.